<template>
  <view class="pickup-index">
    <!-- 分类卡片列表 -->
    <view class="category-list">
      <view 
        v-for="category in categoryList" 
        :key="category.id"
        class="category-card"
        @click="handleCategoryClick(category)"
      >
        <view class="icon">{{ category.icon }}</view>
        <view class="name">{{ category.name }}</view>
        <view class="price">¥{{ category.basePrice }}起</view>
      </view>
    </view>

    <!-- 服务说明 -->
    <view class="service-info">
      <view class="title">💡 服务说明</view>
      <view class="desc-item">• C2C互助模式，用户之间互帮互助</view>
      <view class="desc-item">• 下单后等待其他用户接单</view>
      <view class="desc-item">• 平台担保交易，安全可靠</view>
    </view>
  </view>
</template>

<script>
import { getCategoryList } from '@/api/pickup'

export default {
  data() {
    return {
      categoryList: []
    }
  },
  onLoad() {
    this.loadCategoryList()
  },
  methods: {
    // 加载分类列表
    async loadCategoryList() {
      try {
        uni.showLoading({ title: '加载中...' })
        const categoryList = await getCategoryList()
        this.categoryList = categoryList.filter(item => item.status === 1)
      } catch (error) {
        console.error('加载分类失败:', error)
        uni.showToast({ title: '加载失败', icon: 'none' })
      } finally {
        uni.hideLoading()
      }
    },

    // 点击分类卡片
    handleCategoryClick(category) {
      uni.navigateTo({
        url: `/pages/pickup/create?categoryId=${category.id}`
      })
    }
  }
}
</script>

<style scoped>
.pickup-index {
  padding: 32rpx;
}

.category-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24rpx;
  margin-bottom: 48rpx;
}

.category-card {
  background: #fff;
  border-radius: 16rpx;
  padding: 32rpx;
  text-align: center;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
}

.category-card .icon {
  font-size: 80rpx;
  margin-bottom: 16rpx;
}

.category-card .name {
  font-size: 32rpx;
  font-weight: bold;
  margin-bottom: 8rpx;
}

.category-card .price {
  font-size: 24rpx;
  color: #FF6B6B;
}

.service-info {
  background: #F8F9FA;
  border-radius: 16rpx;
  padding: 32rpx;
}

.service-info .title {
  font-size: 28rpx;
  font-weight: bold;
  margin-bottom: 16rpx;
}

.service-info .desc-item {
  font-size: 24rpx;
  color: #666;
  line-height: 1.8;
}
</style>

